#include "point.h"
#include "vector.h"

using namespace BaseGeo;

Point::Point() : x(0.0), y(0.0), z(0.0) {}

Point::Point(const double x, const double y) : x(x), y(y), z(0.0) {}

Point::Point(const double x, const double y, const double z) : x(x), y(y), z(z) {}

bool Point::operator<(const Point& other) const
{
    if (x > other.x) {
        return false;
    } else if (x < other.x) {
        return true;
    } else {
        return y < other.y;
    }
}


bool Point::operator==(const Point& other) const
{
    return x == other.x && y == other.y;
}


Point Point::operator+(const Coordinate& shift) const
{
    return Point(x + shift.x, y + shift.y, z);
}


Point& Point::operator+=(const Coordinate& shift)
{
    this->x += shift.x;
    this->y += shift.y;

    return *this;
}


double BaseGeo::Distance(const Point& from, const Point& to)
{
    return Vector(from, to).Length();
}


std::ostream& operator<<(std::ostream& stream, const Point& point)
{
    stream << "(" << point.x << ", " << point.y << ", " << point.z << ")";

    return stream;
}